﻿#pragma once
#include <QDialog>
#include <QComboBox>
#include <QPushButton>
#include <QVBoxLayout>
#include <QLabel>
#include <QDateEdit>
#include "orders.h"

class ChangeTicketDialog : public QDialog {
    Q_OBJECT
public:
    ChangeTicketDialog(const orders& oldOrder, QWidget* parent = nullptr);
    int getNewTrainId() const;
    int getNewSeatId() const;
    std::string getNewDate() const;
    bool isSuccess() const;
private:
    QLabel* fromLabel;
    QLabel* toLabel;
    QDateEdit* dateEdit; // 用于日历选择
    QComboBox* trainCombo;
    QComboBox* seatCombo;
    QPushButton* btnConfirm;
    QLabel* infoLabel;
    QLabel* priceLabel; // 新增票价标签
    int newTrainId = -1;
    int newSeatId = -1;
    std::string newDate;
    bool success = false;
    const orders& oldOrderRef;
    void loadTrains();
    void loadSeats(int trainId, const std::string& date);
    void updatePriceLabel(); // 新增票价刷新方法
private slots:
    void onTrainChanged(int idx);
    void onDateChanged(const QDate& date);
    void onConfirmClicked();
};
